﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head><link rel="stylesheet" href="${ctx}/common/common.css">
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
    <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>
    
<style>
.layui-table-header {
	width: 100%;
}

.layui-products {
	border-bottom: 2px solid #e7e7e7;
	/*border-top: 2px solid #e7e7e7;*/
	margin: 10px 0px;
	padding: 5px 0px;
}

.layui-products_li {
	margin-left: 50px;
	border-bottom: 1px dashed #e7e7e7;
}

.layui-products_li:first-child {
	border: none;
}

.layui-col-md4 img {
	margin-right: 5px;
	width: 22px;
	height: 22px;
}

.layui-col-md4 img {
	margin-right: 5px;
	width: 22px;
	height: 22px;
}
</style>
</head>
<body>
<!--主体内容层-->
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-xs12">
            <form class="layui-form">
                <!--输入框内容盒子-->
                <div class="layui-col-xs12">
                    <!--输入框-->
                    <div class="layui-col-xs6">
                        <label class="layui-form-label">生产企业名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enterpriseName" id="enterpriseName" required lay-verify="required"
                                   placeholder="请输入企业名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    
                </div>
                <!--通用按钮盒子-->
                <div class="layui-col-xs12"  style="padding-top: 10px;padding-bottom: 10px">
                    <div style="float: right;" class="layui-btn-group paramBtn">
                        <button data-type="reloadEnterprise" type="button" class="layui-btn layui-btn-sm layui-btn-danger">
                          	查询
                        </button>
                        <button data-type="resetEnterprise" type="reset" class="layui-btn layui-btn-sm layui-btn-danger">
                           	 重置
                        </button>
                        <button data-type="confirmEnterprise" type="button" class="layui-btn layui-btn-sm layui-btn-danger">
                           	 确认
                        </button>
                    </div>
                </div>
            </form>
            <!--通用table表格-->
            <table class="layui-table" id="enterpriseReload" lay-data="{ url:'${ctx }/supplier/billCount/enterprisePage',page:false,groups:5}"
                   lay-filter="demo">
                <thead>
                <tr>
               <!--  https://github.com/sentsin/layui/blob/master/examples/table.html -->
               <!--  checkbox:true, fixed:'left' -->
                	<th lay-data="{type:'checkbox', fixed: 'left',templet:'#isChecked'}"></th>
                    <th lay-data="{field:'name'}">企业名称</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<script id="isChecked" type="text/html">
    {{#  return LAY_CHECKED:true;}}
</script>

</body>
<script>
    layui.use('table', function () {
        var loading=layer.msg("数据加载中...");
        var table = layui.table;
        table.render({
            done:function(){
                layer.close(loading);
            }
        })
        //监听filter为demo的table中的工具条
        table.on('tool(demo)', function (obj) {
        	
     
        });

        var $ = layui.$, active = {
        	reloadEnterprise: function () {//条件查询
                var enterpriseName = document.getElementById("enterpriseName").value;
                table.reload('enterpriseReload', {
                    where: {
                    	enterpriseName: enterpriseName
                    }
                });
                //
                
            },
            resetEnterprise: function () {//重置操作
                table.reload('enterpriseReload', {
                    where: {
                    	enterpriseName: '',
                    }
                })
            },
            confirmEnterprise:function(){//确认操作
            	//定义数据集合
            	var enterprises=[];
            	var enterpriseNameShow='';
            	//查找选中数据
            	var checkStatus = table.checkStatus('enterpriseReload');
            	var data=checkStatus.data;
            	
            	//页面回显
            	for (var i in data){
            		enterpriseNameShow+=data[i].name+",";
                }
            	enterpriseNameShow=enterpriseNameShow.substr(0,enterpriseNameShow.length-1);
                $('#enterpriseId', parent.document).val(JSON.stringify(data));
                $('#enterpriseNameShow', parent.document).html(enterpriseNameShow);
                var index = parent.layer.getFrameIndex(window.name);  
                parent.layer.close(index); 
            }
        };
 
        //给按钮绑定active中的方法
        $(".paramBtn .layui-btn").on("click", function () {
            var type = $(this).data('type');
            //查看是active这个json中是否有type这个方法，如果有调用，如果没有不知心；
            active[type] ? active[type].call() : '';
        })
        
        

    });
</script>
</body>
</html>





